package com.frame.work.frame.deal.device0fe6;

import com.alibaba.fastjson.JSONObject;
import com.frame.work.common.util.JsonToMqtt;
import com.frame.work.frame.deal.base.BaseFrame;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 智能窗帘
 */
@Data
@Deprecated
public class ZhiNengChuangLian_0FE60210 extends BaseFrame {

    private String switchState;

    public ZhiNengChuangLian_0FE60210(String gatewayMac, String data, String type) {

        //将基础数据进行处理
        super(gatewayMac, data);
        return;

//        if (CallType.TYPE_01.equals(type)) {
//            ZhiNengChuangLian_0FE60210_01(gatewayMac, data);
//        }
//        if (CallType.TYPE_07.equals(type)) {
//            ZhiNengChuangLian_0FE60210_07(gatewayMac, data);
//        }

    }

    public void ZhiNengChuangLian_0FE60210_01(String gatewayMac, String data) {
        //处理此设备特有的数据
        this.setSwitchState("");

        //将actions信息放入json对象中
        Map<String, Object> actions = new HashMap();
        //actions.put("switchState",switchState);
        this.setActions(actions);


        //处理好的json对象
        String json = JSONObject.toJSONString(this);
        //将数据发送到mqtt队列中
        JsonToMqtt.sendMQTT(gatewayMac, json);
    }

    public void ZhiNengChuangLian_0FE60210_07(String gatewayMac, String data) {

        //将基础数据进行处理
        //super(gatewayMac,data);

        String deviceType = StringUtils.substring(data, 22, 24);
        String productType = StringUtils.substring(data, 24, 26);
        String cmd_head = StringUtils.substring(data, 36, 38);
        String cmd_3D = StringUtils.substring(data, 42, 44);
        String cmd_tail = StringUtils.substring(data, 46, 48);
        String position = StringUtils.substring(data, 44, 46);

        if ("FF".equals(cmd_head) && "3D".equals(cmd_3D) && "25".equals(cmd_tail)) {
            this.setDeviceType(deviceType);
            this.setProductType(productType);

            //将actions信息放入json对象中
            Map<String, Object> actions = new HashMap();
            actions.put("position", position);
            this.setActions(actions);


            //处理好的json对象
            String json = JSONObject.toJSONString(this);
            //将数据发送到mqtt队列中
            JsonToMqtt.sendMQTT(gatewayMac, json);


        }


    }

}
